package cn.kgc.springcloud.controller;

import cn.kgc.springcloud.entity.Clazz;
import cn.kgc.springcloud.service.ClazzService;
import cn.kgc.springcloud.vo.ClazzVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @Author: 课工场
 * @Version: v1.0  2023/2/27
 * @Description:
 */
@RequestMapping("clazzs")
@RestController
public class ClazzController {

    @Autowired
    private ClazzService clazzService;

    @GetMapping
    public List<ClazzVO> getList(){

        return clazzService.getList();
    }


    @DeleteMapping("{id}")
    public boolean deleteById(@PathVariable Integer id){
        return clazzService.removeById(id);
    }


    @PostMapping
    public Clazz addClazz(String name, MultipartFile file,Integer tagId){
        return clazzService.addClazz(name,file,tagId);
    }

    // 根据班级id查询班级详细信息
    @GetMapping("{id}")
    public Clazz getById(@PathVariable Integer id){
        return clazzService.getById(id);
    }
}
